Based on patches from Hollis Blanchard and Alex Williamson.
Signed-off-by: Keir Fraser <keir@xensource.com>
--- /dev/null
+/*
+ * Platform dependent support for DIG64 platforms.
+ *
+ * Copyright (C) 1999 Intel Corp.
+ * Copyright (C) 1999, 2001 Hewlett-Packard Co
+ * Copyright (C) 1999, 2001, 2003 David Mosberger-Tang <davidm@hpl.hp.com>
+ * Copyright (C) 1999 VA Linux Systems
+ * Copyright (C) 1999 Walt Drummond <drummond@valinux.com>
+ * Copyright (C) 1999 Vijay Chander <vijay@engr.sgi.com>
+ */
+#include <linux/config.h>
+
+#include <linux/init.h>
+#include <linux/delay.h>
+#include <linux/kernel.h>
+#include <linux/kdev_t.h>
+#include <linux/string.h>
+#include <linux/tty.h>
+#include <linux/console.h>
+#include <linux/timex.h>
+#include <linux/sched.h>
+#include <linux/root_dev.h>
+
+#include <asm/io.h>
+#include <asm/machvec.h>
+#include <asm/system.h>
+
+void __init
+dig_setup (char **cmdline_p)
+{
+ unsigned int orig_x, orig_y, num_cols, num_rows, font_height;
+
+ /*
+ * Default to /dev/sda2. This assumes that the EFI partition
+ * is physical disk 1 partition 1 and the Linux root disk is
+ * physical disk 1 partition 2.
+ */
+ ROOT_DEV = Root_SDA2; /* default to second partition on first drive */
+
+#ifdef CONFIG_SMP
+ init_smp_config();
+#endif
+
+ memset(&screen_info, 0, sizeof(screen_info));
+
+ if (!ia64_boot_param->console_info.num_rows
+ || !ia64_boot_param->console_info.num_cols)
+ {
+ printk(KERN_WARNING "dig_setup: warning: invalid screen-info, guessing 80x25\n");
+ orig_x = 0;
+ orig_y = 0;
+ num_cols = 80;
+ num_rows = 25;
+ font_height = 16;
+ } else {
+ orig_x = ia64_boot_param->console_info.orig_x;
+ orig_y = ia64_boot_param->console_info.orig_y;
+ num_cols = ia64_boot_param->console_info.num_cols;
+ num_rows = ia64_boot_param->console_info.num_rows;
+ font_height = 400 / num_rows;
+ }
+
+ screen_info.orig_x = orig_x;
+ screen_info.orig_y = orig_y;
+ screen_info.orig_video_cols = num_cols;
+ screen_info.orig_video_lines = num_rows;
+ screen_info.orig_video_points = font_height;
+ screen_info.orig_video_mode = 3; /* XXX fake */
+ screen_info.orig_video_isVGA = 1; /* XXX fake */
+ screen_info.orig_video_ega_bx = 3; /* XXX fake */
+#ifdef CONFIG_XEN
+ if (!is_running_on_xen())
+ return;
+
+ if (xen_start_info->console.dom0.info_size >=
+ sizeof(struct dom0_vga_console_info)) {
+ const struct dom0_vga_console_info *info =
+ (struct dom0_vga_console_info *)(
+ (char *)xen_start_info +
+ xen_start_info->console.dom0.info_off);
+ screen_info.orig_video_mode = info->txt_mode;
+ screen_info.orig_video_isVGA = info->video_type;
+ screen_info.orig_video_lines = info->video_height;
+ screen_info.orig_video_cols = info->video_width;
+ screen_info.orig_video_points = info->txt_points;
+ screen_info.lfb_width = info->video_width;
+ screen_info.lfb_height = info->video_height;
+ screen_info.lfb_depth = info->lfb_depth;
+ screen_info.lfb_base = info->lfb_base;
+ screen_info.lfb_size = info->lfb_size;
+ screen_info.lfb_linelength = info->lfb_linelen;
+ screen_info.red_size = info->red_size;
+ screen_info.red_pos = info->red_pos;
+ screen_info.green_size = info->green_size;
+ screen_info.green_pos = info->green_pos;
+ screen_info.blue_size = info->blue_size;
+ screen_info.blue_pos = info->blue_pos;
+ screen_info.rsvd_size = info->rsvd_size;
+ screen_info.rsvd_pos = info->rsvd_pos;
+ }
+ screen_info.orig_y = screen_info.orig_video_lines - 1;
+ xen_start_info->console.domU.mfn = 0;
+ xen_start_info->console.domU.evtchn = 0;
+#endif
+}
+
+void __init
+dig_irq_init (void)
+{
+}
# ia64-specific definitions
HAS_ACPI := y
+HAS_VGA := y
VALIDATE_VT ?= n
no_warns ?= n
{
int i, rc;
start_info_t *si;
+ dom0_vga_console_info_t *ci;
struct vcpu *v = d->vcpu[0];
unsigned long max_pages;
//if ( initrd_len != 0 )
// memcpy((void *)vinitrd_start, initrd_start, initrd_len);
+ BUILD_BUG_ON(sizeof(start_info_t) + sizeof(dom0_vga_console_info_t) +
+ sizeof(struct ia64_boot_param) > PAGE_SIZE);
+
/* Set up start info area. */
d->shared_info->arch.start_info_pfn = pstart_info >> PAGE_SHIFT;
start_info_page = assign_new_domain_page(d, pstart_info);
strncpy((char *)si->cmd_line, dom0_command_line, sizeof(si->cmd_line));
si->cmd_line[sizeof(si->cmd_line)-1] = 0;
- bp = (struct ia64_boot_param *)(si + 1);
+ bp = (struct ia64_boot_param *)((unsigned char *)si +
+ sizeof(start_info_t));
bp->command_line = pstart_info + offsetof (start_info_t, cmd_line);
/* We assume console has reached the last line! */
(PAGE_ALIGN(ia64_boot_param->initrd_size) + 4*1024*1024);
bp->initrd_size = ia64_boot_param->initrd_size;
+ ci = (dom0_vga_console_info_t *)((unsigned char *)si +
+ sizeof(start_info_t) +
+ sizeof(struct ia64_boot_param));
+
+ if (fill_console_start_info(ci)) {
+ si->console.dom0.info_off = sizeof(start_info_t) +
+ sizeof(struct ia64_boot_param);
+ si->console.dom0.info_size = sizeof(dom0_vga_console_info_t);
+ }
+
vcpu_init_regs (v);
vcpu_regs(v)->r28 = bp_mpa;
return 1;
}
+int memory_is_conventional_ram(paddr_t p)
+{
+ return (efi_mem_type(p) == EFI_CONVENTIONAL_MEMORY);
+}
+
/*
* Local variables:
* mode: C
# x86-specific definitions
HAS_ACPI := y
+HAS_VGA := y
#
# If you change any of these configuration options then you must
subarch_init_memory();
}
+int memory_is_conventional_ram(paddr_t p)
+{
+ int i;
+
+ for ( i = 0; i < e820.nr_map; i++ )
+ {
+ if ( (e820.map[i].type == E820_RAM) &&
+ (e820.map[i].addr <= p) &&
+ (e820.map[i].size > p) )
+ return 1;
+ }
+
+ return 0;
+}
+
void share_xen_page_with_guest(
struct page_info *page, struct domain *d, int readonly)
{
subdir-y += char
subdir-$(HAS_ACPI) += acpi
-subdir-y += video
+subdir-$(HAS_VGA) += video
#include <xen/delay.h>
#include <xen/guest_access.h>
#include <xen/shutdown.h>
-#include <xen/font.h>
#include <xen/vga.h>
#include <asm/current.h>
#include <asm/debugger.h>
static char opt_console[30] = OPT_CONSOLE_STR;
string_param("console", opt_console);
-/* vga: comma-separated options. */
-static char opt_vga[30] = "";
-string_param("vga", opt_vga);
-
/* conswitch: a character pair controlling console switching. */
/* Char 1: CTRL+<char1> is used to switch console input between Xen and DOM0 */
/* Char 2: If this character is 'x', then do not auto-switch to DOM0 when it */
static int opt_sync_console;
boolean_param("sync_console", opt_sync_console);
-static int xpos, ypos;
-static unsigned char *video;
-
#define CONRING_SIZE 16384
#define CONRING_IDX_MASK(i) ((i)&(CONRING_SIZE-1))
static char conring[CONRING_SIZE];
static char printk_prefix[16] = "";
static int sercon_handle = -1;
-static int vgacon_enabled = 0;
-static int vgacon_keep = 0;
-static int vgacon_lines = 25;
-static const struct font_desc *font;
static DEFINE_SPINLOCK(console_lock);
-/*
- * *******************************************************
- * *************** OUTPUT TO VGA CONSOLE *****************
- * *******************************************************
- */
-
-/* VGA text-mode definitions. */
-#define COLUMNS 80
-#define LINES vgacon_lines
-#define ATTRIBUTE 7
-#define VIDEO_SIZE (COLUMNS * LINES * 2)
-
-/* Clear the screen and initialize VIDEO, XPOS and YPOS. */
-static void cls(void)
-{
- memset(video, 0, VIDEO_SIZE);
- xpos = ypos = 0;
- vga_cursor_off();
-}
-
-static void init_vga(void)
-{
- char *p;
-
- if ( !vgacon_enabled )
- return;
-
- for ( p = opt_vga; p != NULL; p = strchr(p, ',') )
- {
- if ( *p == ',' )
- p++;
- if ( strncmp(p, "keep", 4) == 0 )
- vgacon_keep = 1;
- else if ( strncmp(p, "text-80x", 8) == 0 )
- vgacon_lines = simple_strtoul(p + 8, NULL, 10);
- }
-
- video = setup_vga();
- if ( !video )
- {
- vgacon_enabled = 0;
- return;
- }
-
- switch ( vgacon_lines )
- {
- case 25:
- case 30:
- font = &font_vga_8x16;
- break;
- case 28:
- case 34:
- font = &font_vga_8x14;
- break;
- case 43:
- case 50:
- case 60:
- font = &font_vga_8x8;
- break;
- default:
- vgacon_lines = 25;
- break;
- }
-
- if ( (font != NULL) && (vga_load_font(font, vgacon_lines) < 0) )
- {
- vgacon_lines = 25;
- font = NULL;
- }
-
- cls();
-}
-
-static void put_newline(void)
-{
- xpos = 0;
- ypos++;
-
- if ( ypos >= LINES )
- {
- ypos = LINES-1;
- memmove((char*)video,
- (char*)video + 2*COLUMNS, (LINES-1)*2*COLUMNS);
- memset((char*)video + (LINES-1)*2*COLUMNS, 0, 2*COLUMNS);
- }
-}
-
-static void putchar_console(int c)
-{
- if ( !vgacon_enabled )
- return;
-
- if ( c == '\n' )
- {
- put_newline();
- }
- else
- {
- if ( xpos >= COLUMNS )
- put_newline();
- video[(xpos + ypos * COLUMNS) * 2] = c & 0xFF;
- video[(xpos + ypos * COLUMNS) * 2 + 1] = ATTRIBUTE;
- ++xpos;
- }
-}
-
-int fill_console_start_info(struct dom0_vga_console_info *ci)
-{
- memset(ci, 0, sizeof(*ci));
-
- if ( !vgacon_enabled )
- return 0;
-
- ci->video_type = 1;
- ci->video_width = COLUMNS;
- ci->video_height = LINES;
- ci->txt_mode = 3;
- ci->txt_points = font ? font->height : 16;
-
- return 1;
-}
-
/*
* ********************************************************
* *************** ACCESS TO CONSOLE RING *****************
serial_puts(sercon_handle, kbuf);
for ( kptr = kbuf; *kptr != '\0'; kptr++ )
- putchar_console(*kptr);
+ vga_putchar(*kptr);
guest_handle_add_offset(buffer, kcount);
count -= kcount;
while ( (c = *str++) != '\0' )
{
- putchar_console(c);
+ vga_putchar(c);
putchar_console_ring(c);
}
}
if ( strncmp(p, "com", 3) == 0 )
sercon_handle = serial_parse_handle(p);
else if ( strncmp(p, "vga", 3) == 0 )
- vgacon_enabled = 1;
+ vga_init();
}
- init_vga();
-
serial_set_rx_handler(sercon_handle, serial_rx);
/* HELLO WORLD --- start-of-day banner text. */
printk("\n");
}
- if ( !vgacon_keep )
- vgacon_enabled = 0;
- printk("Xen is %s VGA console.\n",
- vgacon_keep ? "keeping" : "relinquishing");
+ vga_endboot();
/*
* If user specifies so, we fool the switch routine to redirect input
--- /dev/null
+/*
+ * font.h -- `Soft' font definitions
+ *
+ * Created 1995 by Geert Uytterhoeven
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License. See the file COPYING in the main directory of this archive
+ * for more details.
+ */
+
+#ifndef _XEN_FONT_H
+#define _XEN_FONT_H
+
+struct font_desc {
+ const char *name;
+ unsigned width, height, count;
+ const void *data;
+};
+
+extern const struct font_desc font_vga_8x8, font_vga_8x14, font_vga_8x16;
+
+#endif /* _XEN_FONT_H */
/**********************************************/
#include <xen/types.h>
-#include <xen/font.h>
+#include "font.h"
#define FONTDATAMAX (256*14)
/**********************************************/
#include <xen/types.h>
-#include <xen/font.h>
+#include "font.h"
#define FONTDATAMAX (256*16)
/**********************************************/
#include <xen/types.h>
-#include <xen/font.h>
+#include "font.h"
#define FONTDATAMAX (256*8)
#include <xen/compile.h>
#include <xen/init.h>
#include <xen/lib.h>
+#include <xen/mm.h>
#include <xen/errno.h>
#include <xen/event.h>
#include <xen/spinlock.h>
#include <xen/console.h>
-#include <xen/font.h>
#include <xen/vga.h>
#include <asm/io.h>
+#include "font.h"
/* Some of the code below is taken from SVGAlib. The original,
unmodified copyright notice for that code is below. */
* into a single 16-bit quantity */
#define VGA_OUT16VAL(v, r) (((v) << 8) | (r))
-#if defined(__i386__) || defined(__x86_64__)
-# define vgabase 0
-# define VGA_OUTW_WRITE
-# define vga_readb(x) (*(x))
-# define vga_writeb(x,y) (*(y) = (x))
-#endif
+#define vgabase 0 /* use in/out port-access macros */
+#define VGA_OUTW_WRITE /* can use outw instead of 2xoutb */
/*
* generic VGA port read/write
static inline uint8_t vga_mm_r(void __iomem *regbase, uint16_t port)
{
- return readb(regbase + port);
+ return readb((char *)regbase + port);
}
static inline void vga_mm_w(void __iomem *regbase, uint16_t port, uint8_t val)
{
- writeb(val, regbase + port);
+ writeb(val, (char *)regbase + port);
}
static inline void vga_mm_w_fast(void __iomem *regbase, uint16_t port, uint8_t reg, uint8_t val)
{
- writew(VGA_OUT16VAL(val, reg), regbase + port);
+ writew(VGA_OUT16VAL(val, reg), (char *)regbase + port);
}
static inline uint8_t vga_r(void __iomem *regbase, uint16_t port)
return video_found;
}
-static int detect_vga(void)
-{
- /*
- * Look at a number of well-known locations. Even if video is not at
- * 0xB8000 right now, it will appear there when we set up text mode 3.
- *
- * We assume if there is any sign of a video adaptor then it is at least
- * VGA-compatible (surely noone runs CGA, EGA, .... these days?).
- *
- * These checks are basically to detect headless server boxes.
- */
- return (detect_video(ioremap(0xA0000, 0x1000)) ||
- detect_video(ioremap(0xB0000, 0x1000)) ||
- detect_video(ioremap(0xB8000, 0x1000)));
-}
-
/* This is actually code from vgaHWRestore in an old version of XFree86 :-) */
-void *setup_vga(void)
+static void *setup_vga(void)
{
/* The following VGA state was saved from a chip in text mode 3. */
static unsigned char regs[] = {
0x3b, 0x3c, 0x3d, 0x3e, 0x3f, 0x0c, 0x00, 0x0f, 0x08, 0x00
};
+ char *video;
int i, j;
- if ( !detect_vga() )
- {
- printk("No VGA adaptor detected!\n");
- return NULL;
- }
+ if ( memory_is_conventional_ram(0xB8000) )
+ goto no_vga;
inb(VGA_IS1_RC);
outb(0x00, VGA_ATT_IW);
inb(VGA_IS1_RC);
outb(0x20, VGA_ATT_IW);
- return ioremap(0xB8000, 0x8000);
-}
+ video = ioremap(0xB8000, 0x8000);
-void vga_cursor_off(void)
-{
- vga_wcrt(vgabase, VGA_CRTC_CURSOR_START, 0x20);
+ if ( !detect_video(video) )
+ {
+ iounmap(video);
+ goto no_vga;
+ }
+
+ return video;
+
+ no_vga:
+ printk("No VGA adaptor detected!\n");
+ return NULL;
}
static int vga_set_scanlines(unsigned scanlines)
static unsigned font_slot = 0;
integer_param("fontslot", font_slot);
-int vga_load_font(const struct font_desc *font, unsigned rows)
+static int vga_load_font(const struct font_desc *font, unsigned rows)
{
unsigned fontheight = font ? font->height : 16;
uint8_t fsr = vga_rcrt(vgabase, VGA_CRTC_MAX_SCAN); /* Font size register */
{
unsigned i, j;
const uint8_t *data = font->data;
- uint8_t *map = (uint8_t *)__va(0xA0000) + font_slot*2*CHAR_MAP_SIZE;
+ uint8_t *map;
+
+ map = ioremap(0xA0000 + font_slot*2*CHAR_MAP_SIZE, CHAR_MAP_SIZE);
for ( i = j = 0; i < CHAR_MAP_SIZE; )
{
- vga_writeb(j < font->count * fontheight ? data[j++] : 0,
- map + i++);
+ writeb(j < font->count * fontheight ? data[j++] : 0, map + i++);
if ( !(j % fontheight) )
while ( i & (FONT_HEIGHT_MAX - 1) )
- vga_writeb(0, map + i++);
+ writeb(0, map + i++);
}
+
+ iounmap(map);
}
/* First, the sequencer, Synchronous reset */
return 0;
}
+
+
+/*
+ * HIGH-LEVEL INITIALISATION AND TEXT OUTPUT.
+ */
+
+static int vgacon_enabled = 0;
+static int vgacon_keep = 0;
+static int vgacon_lines = 25;
+static const struct font_desc *font;
+
+static int xpos, ypos;
+static unsigned char *video;
+
+/* vga: comma-separated options. */
+static char opt_vga[30] = "";
+string_param("vga", opt_vga);
+
+/* VGA text-mode definitions. */
+#define COLUMNS 80
+#define LINES vgacon_lines
+#define ATTRIBUTE 7
+#define VIDEO_SIZE (COLUMNS * LINES * 2)
+
+void vga_init(void)
+{
+ char *p;
+
+ for ( p = opt_vga; p != NULL; p = strchr(p, ',') )
+ {
+ if ( *p == ',' )
+ p++;
+ if ( strncmp(p, "keep", 4) == 0 )
+ vgacon_keep = 1;
+ else if ( strncmp(p, "text-80x", 8) == 0 )
+ vgacon_lines = simple_strtoul(p + 8, NULL, 10);
+ }
+
+ video = setup_vga();
+ if ( !video )
+ return;
+
+ switch ( vgacon_lines )
+ {
+ case 25:
+ case 30:
+ font = &font_vga_8x16;
+ break;
+ case 28:
+ case 34:
+ font = &font_vga_8x14;
+ break;
+ case 43:
+ case 50:
+ case 60:
+ font = &font_vga_8x8;
+ break;
+ default:
+ vgacon_lines = 25;
+ break;
+ }
+
+ if ( (font != NULL) && (vga_load_font(font, vgacon_lines) < 0) )
+ {
+ vgacon_lines = 25;
+ font = NULL;
+ }
+
+ /* Clear the screen. */
+ memset(video, 0, VIDEO_SIZE);
+ xpos = ypos = 0;
+
+ /* Disable cursor. */
+ vga_wcrt(vgabase, VGA_CRTC_CURSOR_START, 0x20);
+
+ vgacon_enabled = 1;
+}
+
+void vga_endboot(void)
+{
+ if ( !vgacon_enabled )
+ return;
+
+ if ( !vgacon_keep )
+ vgacon_enabled = 0;
+
+ printk("Xen is %s VGA console.\n",
+ vgacon_keep ? "keeping" : "relinquishing");
+}
+
+
+static void put_newline(void)
+{
+ xpos = 0;
+ ypos++;
+
+ if ( ypos >= LINES )
+ {
+ ypos = LINES-1;
+ memmove((char*)video,
+ (char*)video + 2*COLUMNS, (LINES-1)*2*COLUMNS);
+ memset((char*)video + (LINES-1)*2*COLUMNS, 0, 2*COLUMNS);
+ }
+}
+
+void vga_putchar(int c)
+{
+ if ( !vgacon_enabled )
+ return;
+
+ if ( c == '\n' )
+ {
+ put_newline();
+ }
+ else
+ {
+ if ( xpos >= COLUMNS )
+ put_newline();
+ video[(xpos + ypos * COLUMNS) * 2] = c & 0xFF;
+ video[(xpos + ypos * COLUMNS) * 2 + 1] = ATTRIBUTE;
+ ++xpos;
+ }
+}
+
+int fill_console_start_info(struct dom0_vga_console_info *ci)
+{
+ memset(ci, 0, sizeof(*ci));
+
+ if ( !vgacon_enabled )
+ return 0;
+
+ ci->video_type = 1;
+ ci->video_width = COLUMNS;
+ ci->video_height = LINES;
+ ci->txt_mode = 3;
+ ci->txt_points = font ? font->height : 16;
+
+ return 1;
+}
#define MAX_DMADOM_PFN (0x7FFFFFFFUL >> PAGE_SHIFT) /* 31 addressable bits */
+#define CONFIG_VGA 1
+
#ifndef __ASSEMBLY__
// can't find where this typedef was before?!?
#define CONFIG_ACPI 1
#define CONFIG_ACPI_BOOT 1
+#define CONFIG_VGA 1
+
#define HZ 100
#define OPT_CONSOLE_STR "com1,vga"
/* We don't need real ioremap() on Xen/x86. */
#define ioremap(x,l) (__va(x))
+#define iounmap(p) ((void)0)
#define readb(x) (*(volatile char *)(x))
#define readw(x) (*(volatile short *)(x))
+++ /dev/null
-/*
- * font.h -- `Soft' font definitions
- *
- * Created 1995 by Geert Uytterhoeven
- *
- * This file is subject to the terms and conditions of the GNU General Public
- * License. See the file COPYING in the main directory of this archive
- * for more details.
- */
-
-#ifndef _XEN_FONT_H
-#define _XEN_FONT_H
-
-struct font_desc {
- const char *name;
- unsigned width, height, count;
- const void *data;
-};
-
-extern const struct font_desc font_vga_8x8, font_vga_8x14, font_vga_8x16;
-
-#endif /* _XEN_FONT_H */
int guest_remove_page(struct domain *d, unsigned long gmfn);
+/* Returns TRUE if the memory at address @p is ordinary RAM. */
+int memory_is_conventional_ram(paddr_t p);
+
#endif /* __XEN_MM_H__ */
#ifndef _XEN_VGA_H
#define _XEN_VGA_H
-struct font_desc;
+#include <xen/config.h>
-void *setup_vga(void);
-void vga_cursor_off(void);
-int vga_load_font(const struct font_desc *, unsigned rows);
+#ifdef CONFIG_VGA
+void vga_init(void);
+void vga_endboot(void);
+void vga_putchar(int c);
+#else
+#define vga_init() ((void)0)
+#define vga_endboot() ((void)0)
+#define vga_putchar(c) ((void)0)
+#endif
#endif /* _XEN_VGA_H */